package org.tloss.web.jdbc;

import java.sql.ResultSet;
import java.sql.SQLException;

public class ResultSetUtils {
	
	public static Integer getInteger(ResultSet rs, String columnName)
			throws SQLException {
		int result = rs.getInt(columnName);
		if (rs.wasNull()) {
			return null;
		}
		return result;
	}

	public static Double getDouble(ResultSet rs, String columnName)
			throws SQLException {
		double result = rs.getDouble(columnName);
		if (rs.wasNull()) {
			return null;
		}
		return result;
	}

	public static Long getLong(ResultSet rs, String columnName)
			throws SQLException {
		long result = rs.getLong(columnName);
		if (rs.wasNull()) {
			return null;
		}
		return result;
	}

	public static Short getShort(ResultSet rs, String columnName)
			throws SQLException {
		short result = rs.getShort(columnName);
		if (rs.wasNull()) {
			return null;
		}
		return result;
	}

	public static Byte getByte(ResultSet rs, String columnName)
			throws SQLException {
		byte result = rs.getByte(columnName);
		if (rs.wasNull()) {
			return null;
		}
		return result;
	}

	public static Float getFloat(ResultSet rs, String columnName)
			throws SQLException {
		float result = rs.getFloat(columnName);
		if (rs.wasNull()) {
			return null;
		}
		return result;
	}

	public static Boolean getBoolean(ResultSet rs, String columnName)
			throws SQLException {
		boolean result = rs.getBoolean(columnName);
		if (rs.wasNull()) {
			return null;
		}

		return result;
	}

}